<%@ include file="/common/taglibs.jsp" %>
<script type="text/javascript" src="<c:url value='/js/util.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.numeric.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.formatCurrency-1.4.0.pack.js'/>"></script>
<script src="<c:url value='/js/jquery/jqueryFileTree/jqueryFileTree.js' />" type="text/javascript"></script>
<script src="<c:url value='/js/file-browser.js' />" type="text/javascript"></script>
<link href="<c:url value='/js/jquery/jqueryFileTree/jqueryFileTree.css' />" rel="stylesheet" type="text/css" />
<link href="<c:url value='/css/dhtmlxcombo_paylineitem.css' />"
	rel="stylesheet" type="text/css" />
	<link href="<c:url value='/css/jquery/jquery.qtip.css' />"
	rel="stylesheet" type="text/css" />
<script type="text/javascript">
	
	$(document).ready(function() {

	//	$(function(){
	//	    var tabindex = 1;
	//	    $('input,select, div').each(function() {
	//	        if (this.type != "hidden" && this.type!='button') {
	//	            var $input = $(this);
	//	            $input.attr("tabindex", tabindex);
	//	            tabindex++;
	//	        }
	///	    });
	//	});
	//	
	  $("#donorAwardNumber").focus();
		<c:choose>
			<c:when test="${!empty mode && mode == 'editMode'}">
				$('#pageTitle').text('<spring:message code="editDonoraward.heading.view" />');
			</c:when>
			<c:otherwise>
				$('#pageTitle').text('<spring:message code="editDonoraward.heading" />');
			</c:otherwise>
		</c:choose>		
		
		$.validator.addMethod("dateValidation", 
                function(value, element) {
					 var date_ini = new Date($('#startDate').val()).getTime();
					 var date_end = new Date($('#endDate').val()).getTime();
					 if (date_ini > date_end) {
									return false;
								   }
						return true;
                     }, 
                    "The Donor Award End date should be after Donor Award Start Date."

		    );
		$("#editDonorawardForm").validate({
			rules : {
				'donor.id' : "required",
				donorAwardNumber : {
					required : true
				},
				donorAwardDesc : {
					required : true
				},
				startDate : {
					required : true,
					date : true
				},
				endDate : {
					required : true,
					date : true,
					dateValidation:true
				},
				allocatedAmount : {
					required : true
				},
				directFunds : {
					required : true
				},
				donorawardstatus : {
					required : true
				},
				'donorawardtype.id' : "required"
			},
			   messages: {
				   'donorawardtype.id': "Please select donor award type",
				   'donor.id': "Please select donor"
				     
				   }
		});	
		$(".dhx_combo_input").rules("add", { 
  			required:true, 
  			});
		
		 $("#save").bind("click",function(){
	      		var t= setTimeout(function(){
	      		$('.dhx_combo_input').click();
	      		$('.input-full-width uneditable text_grey').click();
	      		},300);
	      		
	      		if($('.dhx_combo_input').eq(0).val() == ''){
	 				 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
	      		}
	       		 $('.dhx_combo_input').eq(0).blur(function() {
	     			 if($('.dhx_combo_input').eq(0).val()!= ''){
	     				 $('.dhx_combo_box ').eq(0).css("border-color", "#BDBCBD");
	     			 }
	     		 });
	       		 $('.dhx_combo_input').eq(0).keypress(function(event) {
	    			  if ( event.which == 8 || event.which == 9  || event.which == 40) {
	    				  var inputVal = $('.dhx_combo_input').eq(0).val().length;
	    			 		if(inputVal == 1){
	    					 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
	    					 }else if(inputVal == 0){
	    						 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
	    					}else{
	    						 $('.dhx_combo_box ').eq(0).css("border-color", "#BDBCBD");
	    					 }
	    				   }
	    			});
	      		 
		 	if($('.dhx_combo_input').eq(1).val() == ''){
				 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
				 }
		
     		 $('.dhx_combo_input').eq(1).blur(function() {
   			 if($('.dhx_combo_input').eq(1).val()!= ''){
   				 $('.dhx_combo_box ').eq(1).css("border-color", "#BDBCBD");
   			 }
   		 });
     		 $('.dhx_combo_input').eq(1).keypress(function(event) {
  			  if ( event.which == 8 || event.which == 9  || event.which == 40) {
  				  var inputVal = $('.dhx_combo_input').eq(1).val().length;
  			 		if(inputVal == 1){
  					 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
  					 }else if(inputVal == 0){
  						 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
  					}else{
  						 $('.dhx_combo_box ').eq(1).css("border-color", "#BDBCBD");
  					 }
  				   }
  			});
      		
		 	if($('.dhx_combo_input').eq(2).val() == ''){
				 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
				 }
		
      		 $('.dhx_combo_input').eq(2).blur(function() {
    			 if($('.dhx_combo_input').eq(2).val()!= ''){
    				 $('.dhx_combo_box ').eq(2).css("border-color", "#BDBCBD");
    			 }
    		 });
      		 $('.dhx_combo_input').eq(2).keypress(function(event) {
   			  if ( event.which == 8 || event.which == 9  || event.which == 40) {
   				  var inputVal = $('.dhx_combo_input').eq(2).val().length;
   				
   			 		if(inputVal == 1){
   					 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
   					 }else if(inputVal == 0){
   						 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
   					}else{
   						 $('.dhx_combo_box ').eq(2).css("border-color", "#BDBCBD");
   					 }
   				   }
   			});

			 	if($('.dhx_combo_input').eq(3).val() == ''){
					 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
					 }
			
	   		 $('.dhx_combo_input').eq(3).blur(function() {
	 			 if($('.dhx_combo_input').eq(3).val()!= ''){
	 				 $('.dhx_combo_box ').eq(3).css("border-color", "#BDBCBD");
	 			 }
	 		 });
	   		 $('.dhx_combo_input').eq(3).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(3).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(3).css("border-color", "#BDBCBD");
						 }
					   }
				});
	  

	    });
		$("#startDate").change(enableProjectEndDatefn);
		<c:if test="${empty donoraward.fiscalyear}">
		$("#startDate").change();
		</c:if>
		

		var donorId = '${donoraward.donor.id}';
		if(donorId !== null || donorId.length > 0)
		$("#donor.id").val( donorId ).attr('selected',true);
		
		$("#creationDate").val($.format.date($("#creationDate").val(), "MM/dd/yyyy"));
		
		$("#updationDate").val($.format.date($("#updationDate").val(), "MM/dd/yyyy"));
// 		var pickerOpts = {
// 				onClose: function() { this.focus(); }
// 			};
			
		
				$("#startDate").datepicker();
			
				$("#endDate").datepicker();
			
		$('#editButton').click(function() {
			$("#startDate").datepicker("enable");
			
			$("#endDate").datepicker("enable");
			var inputs = $('#editDonorawardForm input:not(.uneditable)');
			var selects = $('#editDonorawardForm select');
			var checkboxes = $('#editDonorawardForm checkbox');
	

			inputs.each(function() {
				$(this).removeAttr('readonly');
// 				$(this).removeAttr('disabled');
			});
			selects.each(function() {
				$(this).removeAttr('readonly');
				$(this).removeAttr('disabled');
			});
			checkboxes.each(function() {
				$(this).removeAttr('readonly');
				$(this).removeAttr('disabled');
			});
			$(this).attr('disabled','disabled');
			$('#cancelEditButton').removeAttr('disabled');
			$('#save').removeAttr('disabled');
			//$('#saveAndViewDonor').removeAttr('disabled');
		});
	

		<c:if test="${donoraward.id !=null and donoraward.id gt 0}">
			var inputs = $('#editDonorawardForm input[type="text"]:not(.uneditable)');
			var selects = $('#editDonorawardForm select');
			var checkboxes = $('#editDonorawardForm checkbox');
	
			inputs.each(function() {
				$(this).attr('readonly','readonly');
			});
			
			$("#startDate").datepicker("disable");	
			$("#endDate").datepicker("disable");
			$("#startDate").removeAttr("disabled");	
			$("#endDate").removeAttr("disabled");
	
			
			selects.each(function() {
				$(this).attr('disabled','disabled');
			});
			checkboxes.each(function() {
				$(this).attr('readonly','readonly');
			});
			$('#cancelEditButton').attr('disabled','disabled');
			$('#save').attr('disabled','disabled');
			//$('#saveAndViewDonor').attr('disabled','disabled');
		</c:if>
		
		$('#cancelEditButton').click(function() {
			var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
			if (ans) {
				var uri = '${rc.requestUri}';
				<c:if test="${donoraward.id !=null and donoraward.id gt 0}">
				uri += "?id=${donoraward.id}";
				</c:if>
				loadDiv('content', uri);
			}
		});
		
		$('#cancelButton').click(function() {
			var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
			if (ans) {
				loadDiv('content', 'findDonoraward.do');
			}
		});
		
		$('input#dummySelectFile').change(function() {
			$('#attachmentName').val(this.value);
		});

		$('#chooseFileButton').click(function() {
			var path = $('#attachmentName').val();
			if($.trim(path) == '') {
				path = 'S:\\Scanned Documents\\Donor Awards';
			} else {
				if( path.charAt(path.length - 4) == '.') {
					path = path.substring(0, path.lastIndexOf('\\'));	
				}
			}
			
			var fileBrowser = new FileBrowser(path,'<c:url value="/js/jquery/jqueryFileTree/connectors/jqueryFileTree.jsp" />', 
				function(file) {
					$('#attachmentName').val(file);
				}
			);
			fileBrowser.open();
		});
		
		$('#viewAgreementButton').click(function() {
			var fileName = $('#attachmentName').val();
			if('' != fileName) {
				window.open("<c:url value='/openFile.do' />?fileName=" + fileName, "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
			}
		});
		
		$('.attachmentPath').click(function() {
			var fileName = $('div', this).text();
			window.open("<c:url value='/openFile.do' />?fileName=" + fileName, "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
		});
		
		$('#directFunds').numeric();
		
		$('#directFunds').blur(function() {
			if($('#directFunds').val().length > 0){
				$('#directFunds').formatCurrency('#directFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: -2});
				showSubstitute(true, 'directFundsLabel','directFunds');
			}
		});
		
		$('#directFundsLabel').click(function() {
			showSubstitute(false, 'directFundsLabel','directFunds');	
		});
		
		$('#directFunds').formatCurrency('#directFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: -2});
		showSubstitute(true, 'directFundsLabel','directFunds');
		
		$('#indirectFunds').numeric();
		
		$('#indirectFunds').blur(function() {
			$('#indirectFunds').formatCurrency('#indirectFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: -2});
			showSubstitute(true, 'indirectFundsLabel','indirectFunds');
		});
		
		$('#indirectFundsLabel').click(function() {
			showSubstitute(false, 'indirectFundsLabel','indirectFunds');	
		});
		
		$('#indirectFunds').formatCurrency('#indirectFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: -2});
		showSubstitute(true, 'indirectFundsLabel','indirectFunds');
		
		$('#obligatedAmount').formatCurrency('#obligatedAmountLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: -2});
		showSubstitute(true, 'obligatedAmountLabel', 'obligatedAmount');
		
		$("input").bind("keydown", function(event) {
		      // track enter key
		      var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
		      if (keycode == 13) { // keycode for enter key
		         // force the 'Enter Key' to implicitly click the Update button
		         document.getElementById('donorAwardNumber').click();
		         return false;
		      } else  {
		         return true;
		      }
		   }); // end of function
		   
		<c:if test="${donoraward.id !=null and donoraward.id gt 0}">
        	var modificationLocationBrowser = new FileBrowser('S:\\Scanned Documents\\Donor Awards','<c:url value="/js/jquery/jqueryFileTree/connectors/jqueryFileTree.jsp" />', 
        			function(file) {
        				$('#modificationDocumentLocation').val(file);
        			},
        			function(dir) {
        			},
        			function() {
        				$('#doSave').click();
        				// OK Listener
        			},
        			function() {
        				$('#doSave').click();
        				// OK Listener
        			}
        	);
        	modificationLocationBrowser.setTitle('Select modification document file');
        	
        	$('#save').click(function() {
        		var prevStartDate = '${donoraward.prevStartDate}';
        		var prevEndDate = '${donoraward.prevEndDate}';
        		var prevDirectFunds = ${donoraward.prevDirectFunds};
        		var prevIndirectFunds = ${donoraward.prevIndirectFunds};
        		var prevStatus = '';
        		<c:if test="${!empty donoraward.prevStatusId}">
        			prevStatus = '${donoraward.prevStatusId}';
        		</c:if>
        		
        		var currStartDate = $('#startDate').val();
        		var currEndDate = $('#endDate').val();
        		var currDirectFunds = $('#directFunds').val();
        		var currFDirectFunds = parseFloat(currDirectFunds) ? parseFloat(currDirectFunds) : 0;
        		var currIndirectFunds = $('#indirectFunds').val();
        		var currFIndirectFunds = parseFloat(currIndirectFunds) ? parseFloat(currIndirectFunds) : 0;
        		var currStatus = $('#donorawardStatus').val();
        		
        		if(prevStartDate != currStartDate 
        			|| prevEndDate != currEndDate
        			|| prevDirectFunds != currFDirectFunds
        			|| prevIndirectFunds != currFIndirectFunds
        			|| prevStatus != currStatus) {
        			modificationLocationBrowser.open();
        		} else {
        			$('#doSave').click();
        		}
        	});
    	</c:if>
    

    	
    	
	});
	
	<c:if test="${donoraward.id ==null}">
	
	$('#save').click(function() {
		$('#doSave').click();
	});
	</c:if>
	
	$('.close-button').click(function() {
		//if(confirm('Are you sure you want to close the form?')) {
			window.location = '../secure/showDashboard.do';
		//}	
	});
	function showSubstitute(show, subId, tobeSubId) {
		if(show) {
			$('#' + subId).css('display', 'block');
			$('#' + tobeSubId).css('display', 'none');
		} else {
			$('#' + subId).css('display', 'none');
			$('#' + tobeSubId).css('display', 'block');
			$('#' + tobeSubId).focus();
		}
	}



	$('.edit-donor-link').click(function() {
		var idVal = document.getElementsByName("donor.id")[0].value;
		var uri = '${rc.requestUri}';
		var queryString = '${rc.queryString}';
		var url = uri + "?" + queryString;
		loadDiv('content', 'showEditDonor.do?id=' + idVal + '&prevUrl=' + url);
	});

	$("#indirectFunds").blur(function() {
		var total = 0;
		var dirFund = parseFloat(jQuery.trim($("#directFunds").val()));
		var inDirFund = parseFloat(jQuery.trim($("#indirectFunds").val()));
		total += (!isNaN(dirFund) ? dirFund : 0) + (!isNaN(inDirFund) ? inDirFund : 0);

		$('#obligatedAmount').val(total);
		$('#obligatedAmount').formatCurrency('#obligatedAmountLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: -2});
	});

	$("#directFunds").blur(function() {
		var total = 0;
		var dirFund = parseFloat(jQuery.trim($("#directFunds").val()));
		var inDirFund = parseFloat(jQuery.trim($("#indirectFunds").val()));
		total += (!isNaN(dirFund) ? dirFund : 0) + (!isNaN(inDirFund) ? inDirFund : 0);

		$('#obligatedAmount').val(total);
		$('#obligatedAmount').formatCurrency('#obligatedAmountLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: -2});
	});
	$('.cancel-button').click(function() {
		var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
		if (ans) {
			//location.href = '../secure/showDashboard.do';
			loadDiv('content', 'refreshDashboard.do');
		}
	});

	function getFiscalYear() {
		var str1 = document.getElementById("startDate").value;
		var dateParts = str1.split("/");
		var mon1 =  parseInt(dateParts[0]);
		var dt1 =  parseInt(dateParts[1]);
		var yr1 =  parseInt(dateParts[2]);
		
		if(yr1 < 100){
			yr1 += 2000;
		}
		
		//var mon1 = parseInt(str1.substring(0, 2), 10);
		//var dt1 = parseInt(str1.substring(3, 5), 10);
		//var yr1 = parseInt(str1.substring(6, 10), 10);
		var dt2 = 1;
		var mon2 = 10;
		var date1 = new Date(yr1, mon1, dt1);
		var date2 = new Date(yr1, mon2, dt2);
		if (isNaN(yr1)) {
			//do nothing
		} else {

			if (date1 >= date2) {
				document.getElementById("fiscalyear").value = yr1 + 1;
			} else {
				document.getElementById("fiscalyear").value = parseInt(yr1);
			}
		}
	}

	function enableProjectEndDatefn()
    {
    	
    	if($("#startDate").val()=="")
    	{
    		//do nothing
    	}
    	else
    	{
    		
    		$("#endDate").removeAttr('readonly');
    		$("#endDate").removeAttr('disabled');
    	}
	}
	
	$('#directFundsLabel').focus(function() {
		$('#directFundsLabel').css('display', 'none');
		$('#directFunds').css('display', 'block');
		$('#directFunds').focus();
	});
	
	$('#indirectFundsLabel').focus(function() {
		$('#indirectFundsLabel').css('display', 'none');
		$('#indirectFunds').css('display', 'block');
		$('#indirectFunds').focus();
	});
	
	$("#endDate").change(function() {
		var date_ini = new Date($('#startDate').val()).getTime();
		var date_end = new Date($('#endDate').val()).getTime();
		if (isNaN(date_ini)) {
		    //if required we will add code
		}
		else if (isNaN(date_end)) {
		//if required we will add code
		}
		else if (date_ini > date_end) {
			
		    alert("The Donor Award End date should be after Donor Award Start Date");
		   
		}

	});

	function showSubstituteAnchor(show, subId, tobeSubId) {
		if(show) {
			$('#' + subId).css('display', 'inline');
			$('#' + tobeSubId).css('display', 'none');
		} else {
			$('#' + subId).css('display', 'none');
			$('#' + tobeSubId).css('display', 'inline');
		}
	}
	  var z1 = dhtmlXComboFromSelect("donorawardtype_id",274);
	  z1.enableFilteringMode(true);
	  
	  var z2 = dhtmlXComboFromSelect("donor.id",274);
	  z2.enableFilteringMode(true);
	  
	  var z3 = dhtmlXComboFromSelect("donorawardStatus",274);
	  z3.enableFilteringMode(true);

	
</script>
<div id="editDonorawardDiv">
	<form:form name="editDonorawardForm" id="editDonorawardForm" action="saveDonoraward.do" method="post" modelAttribute="donoraward">
		<input type="hidden" name="mode" value="${mode }" id="mode"/>
		<form:hidden path="id" />
        <form:hidden path="modificationDocumentLocation" />
		<div class="main_form">
	    	<div class="form_head">
	    		<a href="#" class="close-button gray_btn floatR" tabindex="-1">Close Form</a><br class="clear" />
	    	</div>
	    	<div class="form_cont">
	    	<table cellspacing="5" width="100%">
					<tr class="row">
						<td class="input-field" colspan="5" style="text-align: center;">
							<%@ include file="/common/messages.jsp" %>
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editDonoraward.label.donorAwardNumber" /></td>
						<td class="input-field">
							<form:input path="donorAwardNumber" cssClass="input-full-width-req text_blue" tabindex="1"/>
							<form:errors path="donorAwardNumber" cssClass="error" />
						</td>						
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="editDonoraward.label.donorawardtype" /></td>
						<td class="input-field">
							<form:select path="donorawardtype.id" id="donorawardtype_id" cssClass="input-full-width-req text_blue" tabindex="9">
						        <form:option value="" label="" />
								<form:options items="${donorawardtypeList}" itemValue="id" itemLabel="displayName" />
							</form:select>
							<form:errors path="donorawardtype.id" cssClass="error" />
						</td>
						
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editDonoraward.label.donor" /></td>
						<td class="input-field" nowrap="nowrap">
							<form:select path="donor.id" cssClass="input-full-width-req text_blue" tabindex="2">
								<c:choose>
									<c:when test="${donor.id !=null and donor.id gt 0}">
										<form:option value="${donor.id}" label="${donor.donorName}"></form:option>
									</c:when>
									<c:otherwise>
										<form:option value="" label="" />
									</c:otherwise>
								</c:choose>
								<form:options items="${donorList}" itemValue="id" itemLabel="donorName" />
							</form:select>
                            
						</td>
						<td width="50"><security:authorize ifAnyGranted="ROLE_ADMIN,ROLE_GRANTS,ROLE_STAFF,ROLE_KM,ROLE_SENIOR_MANAGEMENT">
                              <input type="button"  class="edit-donor-link blue_btn" value="<spring:message code="label.view" />" tabindex="-1"/>
                            </security:authorize>
							<form:errors path="donor.id" cssClass="error" /></td>
						
						<td class="label"><spring:message code="editDonoraward.label.fiscalyear" /></td>
						<td class="input-field">
							<form:input path="fiscalyear" cssClass="input-full-width text_white" tabindex="10"/>
							<form:errors path="fiscalyear" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
					
						<td class="label"><spring:message code="editDonoraward.label.donorAwardDesc" /></td>
						<td class="input-field">
							<form:input path="donorAwardDesc" cssClass="input-full-width-req text_blue" tabindex="3"/>
							<form:errors path="donorAwardDesc" cssClass="error" />
						</td>
					
						<td width="50">&nbsp;</td>
						
						<td class="label">Award Agreement File Location</td>
						<td class="input-field file-browser-container" nowrap="nowrap">
							<form:input path="attachmentName" cssClass="input-full-width text_white" tabindex="11"/>
							<input id="chooseFileButton" class="blue_btn" type="button" value="Edit" tabindex="-1"/>
							<input id="viewAgreementButton" class="blue_btn uneditable" type="button" value="View" tabindex="-1"/>
							<form:errors path="attachmentName" cssClass="error" />
						</td>
						
							
						
					</tr>
					<tr class="row">
						
						<td class="label"><spring:message code="editDonoraward.label.startDate" /></td>
						<td class="input-field">
							<form:input path="startDate" cssClass="input-full-width-req text_blue" onchange="getFiscalYear()" tabindex="4"/>
							<form:errors path="startDate" cssClass="error" />
						</td>
						
						<td width="50">&nbsp;</td>
						
						<td class="label"><spring:message code="editDonoraward.label.memonotes" /></td>
						<td class="input-field">
							<form:input path="memonotes" cssClass="input-full-width text_white" tabindex="12"/>
							<form:errors path="memonotes" cssClass="error" />
						</td>
					</tr>
	
					<tr class="row">
						<td class="label"><spring:message code="editDonoraward.label.endDate" /></td>
						<td class="input-field">
							<form:input path="endDate" cssClass="input-full-width-req text_blue" tabindex="5"/>
							<form:errors path="endDate" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.createdBy" /></td>
						<td class="input-field">
							<form:input readonly="true" path="createdBy.fullName" cssClass="input-full-width uneditable text_grey" />
							<form:errors path="createdBy" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
					
						<td class="label"><spring:message code="editDonoraward.label.directFunds" /></td>
						<td class="input-field">
							<form:input path="directFunds" cssClass="input-full-width-req text_blue" />
							<input type="text" value="&nbsp;" readonly="readonly"  id="directFundsLabel" class="uneditable input-sub input-full-width-req text_blue" tabindex="6"/>
							<form:errors path="directFunds" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.creationDate" /></td>
						<td class="input-field">
							<form:input readonly="true" path="creationDate" cssClass="input-full-width uneditable text_grey"/>
							<form:errors path="creationDate" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editDonoraward.label.indirectFunds" /></td>
						<td class="input-field">
							<form:input path="indirectFunds" cssClass="input-full-width-req text_blue" tabindex="7"/>
							<input type="text" value="&nbsp;" readonly="true" id="indirectFundsLabel" class="uneditable input-sub input-full-width-req text_blue"/>
							<form:errors path="indirectFunds" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.updatedBy" /></td>
						<td class="input-field">
							<form:input readonly="true" path="updatedBy.fullName" cssClass="input-full-width uneditable text_grey" />
							<form:errors path="updatedBy" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editDonoraward.label.obligatedAmount" /></td>
						<td class="input-field">
							<form:input path="obligatedAmount" readonly="true" cssClass="input-full-width-req text_grey" tabindex="-1"/>
							<input type="text" value="&nbsp;" readonly="true" id="obligatedAmountLabel" class="uneditable input-sub input-full-width-req text_grey" tabindex="-1"/>
							<form:errors path="obligatedAmount" cssClass="error" />
						</td>					
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.updationDate" /></td>
						<td class="input-field">
							<form:input readonly="true" path="updationDate" cssClass="input-full-width uneditable text_grey"/>
							<form:errors path="updationDate" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editDonoraward.label.donorawardStatus" /></td>
						<td class="input-field">
							<form:select id="donorawardStatus" path="donorawardstatus.id" cssClass="input-full-width-req text_blue" tabindex="8">
							<c:choose>
								<c:when test="${donoraward.id !=null and donoraward.id gt 0}">
								     <form:option value="" label="" />
									<form:options items="${donorawardstatusList}" itemValue="id" itemLabel="displayName" />
								</c:when>
								<c:otherwise>
									<form:option value="5" label="Active" />
									<form:option value="6" label="Pending" />
								</c:otherwise>
							</c:choose>
							</form:select>
							<form:errors path="donorawardstatus.id" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
                        <td class="label">&nbsp;</td>
                        <td></td>
					<%--   <tr class="row">
						<td class="label"><spring:message
								code="editDonoraward.label.donorawardModifications" /></td>
						<td class="input-field"><form:textarea
								path="donorawardmodifications.id" 
								items="${donorawardmodificationsList}" itemValue="id"
									itemLabel="modificationNumber"  cssClass="input-full-width" /></td>
						<td><form:errors path="donorawardmodifications"
								cssClass="error" /></td>
					</tr> --%>
                    </tr>
					
	              	<tr class="row">
						<td class="input-field" align="center" colspan="5">
							<c:choose>
								<c:when test="${donoraward.id !=null and donoraward.id gt 0}">
                                  <security:authorize ifAnyGranted="ROLE_ADMIN,ROLE_GRANTS">
									<input id="editButton" type="button" value="Edit" class="blue_btn" tabindex="-1"/>
                                  </security:authorize>
									<input id="cancelEditButton" disabled="disabled" type="button" value="Cancel Edit" class="gray_btn" tabindex="-1"/>
								</c:when>
								<c:otherwise>
									<input id="cancelButton" type="button" value="Cancel" class="blue_btn" tabindex="-1"/>
								</c:otherwise>
							</c:choose>
                            <input type="button" id="save" class="blue_btn" value="<spring:message code="editDonoraward.button.save" />" tabindex="-1">
							<sj:submit id="doSave" target="content" key="editDonoraward.button.save" validate="true" cssClass="hiddenSubmitButton" tabindex="-1" />
							<%-- <sj:submit id="saveAndViewDonor" target="editDonorawardDiv" key="editDonoraward.button.saveandviewdonor" validate="true" cssClass="blue_btn" tabindex="-1"/> --%>				
						</td>
					</tr>						
				</table>
				<br class="clear" />
              <c:if test="${isGrantUser || isStaffUser || isKmUser || isSrManagementUser || isAdminUser }">
				<table class="tablesorter">
					<thead>
						<tr>
							<th>ID</th>
							<th>Modification Type</th>
							<th>Modified From</th>
							<th>Modified To</th>
							<th>Modified Date</th>
							<th>Modified By</th>
							<th>File Location of Modified Document</th>
						</tr>
					</thead>
					<tbody>
					<c:choose>
						<c:when test="${fn:length(donoraward.donorawardmodifications) > 0}">
						<c:forEach items="${donoraward.donorawardmodifications}" var="donorawardmodification">
							<tr>
								<td>${donorawardmodification.id}</td>
								<td>${donorawardmodification.modificationType.modificationTypeDesc}</td>
								<td>${donorawardmodification.modifiedFrom}</td>
								<td>${donorawardmodification.modifiedTo}</td>
								<td>${donorawardmodification.formattedModifiedDate}</td>
								<td>${donorawardmodification.modifiedBy.fullName}</td>
								<td><a href="#" onclick="return false;" class="attachmentPath"><div>${donorawardmodification.attachment}</div></a></td>
							</tr>
						</c:forEach>
						</c:when>
						<c:otherwise>
							<tr>
								<td colspan="7" style="padding-left: 10px;">No modifications found.</td>
							</tr>
						</c:otherwise>
					</c:choose>
					</tbody>
				</table>
              </c:if>
			</div>
		</div>
	</form:form>
</div>
